import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDLegionDonation {
	/**ID*/
	id,
	/**名字*/
	name,
	/**描述*/
	desc,
	/**捐献消耗道具ID*/
	costItemId,
	/**捐献消耗道具数量（0：代表免费）*/
	costItemNum,
	/**捐献奖励（组）*/
	dropid,
	/**每日限制次数*/
	dailyLimit,
	/**捐献增加的公会经验*/
	expGain,

	/**枚举数量*/
	EnumCount
}



export class CDLegionDonation{
	/**ID*/
	public id: number;
	/**名字*/
	public name: number;
	/**描述*/
	public desc: number;
	/**捐献消耗道具ID*/
	public costItemId: number;
	/**捐献消耗道具数量（0：代表免费）*/
	public costItemNum: number;
	/**捐献奖励（组）*/
	public dropid: number;
	/**每日限制次数*/
	public dailyLimit: number;
	/**捐献增加的公会经验*/
	public expGain: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDLegionDonation.id: return this.id;
			case E_CDLegionDonation.name: return this.name;
			case E_CDLegionDonation.desc: return this.desc;
			case E_CDLegionDonation.costItemId: return this.costItemId;
			case E_CDLegionDonation.costItemNum: return this.costItemNum;
			case E_CDLegionDonation.dropid: return this.dropid;
			case E_CDLegionDonation.dailyLimit: return this.dailyLimit;
			case E_CDLegionDonation.expGain: return this.expGain;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDLegionDonation.id: this.id = v; break;
			case E_CDLegionDonation.name: this.name = v; break;
			case E_CDLegionDonation.desc: this.desc = v; break;
			case E_CDLegionDonation.costItemId: this.costItemId = v; break;
			case E_CDLegionDonation.costItemNum: this.costItemNum = v; break;
			case E_CDLegionDonation.dropid: this.dropid = v; break;
			case E_CDLegionDonation.dailyLimit: this.dailyLimit = v; break;
			case E_CDLegionDonation.expGain: this.expGain = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDLegionDonation> = new HashMap<number, CDLegionDonation>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDLegionDonation[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDLegionDonation();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].name = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].desc = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].costItemId = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].costItemNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dropid = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dailyLimit = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].expGain = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDLegionDonation{
		return this.datas ? this.datas.get(id) : null;
	}
}
